<?php
namespace app\supermanager\model;
use think\Model;
use app\common\traits\model\TraitModel;

class Users extends Model
{
	use TraitModel;

	protected $autoWriteTimestamp = 'timestamp';
    protected $createTime = 'created_at';
    protected $updateTime = 'updated_at';
	protected $table = 'users';
	
	public function getStatusAttr($value)
    {
        $status = [0=>'未绑定',1=>'已绑定'];
        return $status[$value];
    }

    public function getSexAttr($value)
    {
        $status = [0 => '男', 1 => '女', 2 => '保密'];
        return $status[$value];
    }
    public function getAuthentication($value)
    {
    	if(empty($value)){
    		return '未认证';
    	}
        $status = [0=>'未认证',1=>'已认证'];
        return $status[$value];
    }
    public function camps(){
        return $this->belongsTo('Camps','camp_id');
    }
	
	public function caravans(){
        return $this->hasOne('Caravans','user_id');
    }
	
	/**
	 * 获取会员信息列表
	 */
	public function getUserList($querys = [])
	{
		return $this->getInfoList($querys);
	}

	/**
	 * 获取会员信息详情
	 */
	
	public function getUserInfo($id){
	    return $this->get(['id' => $id]);
	}
	
	
	/**
	 * 获取会员余额
	 */
	public function blance($user_id=null){
	   return model('\\app\\common\\model\\Capitals')->getBlance($user_id);
	} 
	/**
	 * 获取会员积分
	 */
	public function integral($user_id=null){
	   return model('\\app\\common\\model\\Capitals')->getIntegral($user_id);
	} 
}